package dale.web.link.repository;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import dale.web.common.model.Condition;
import dale.web.link.model.Link;

@Repository
public class LinkRepositoryBatis implements LinkRepository {
	
	protected SqlSessionTemplate template;

	@Autowired
	public LinkRepositoryBatis(SqlSessionTemplate template) {
		this.template = template;
	}
	
	@Override
	public List<Link> selectAll() {
		return template.selectList("Link.selectAll");
	}
	
	@Override
	public int count(Condition<Link> condition) {
		return template.selectOne("Link.count", condition);
	}

	@Override
	public List<Link> selectList(Condition<Link> condition, int offset, int limit) {
		RowBounds bounds = new RowBounds(offset, limit);
		return template.selectList("Link.selectList", condition, bounds);
	}

	@Override
	public Link selectOne(Integer no) {
		return template.selectOne("Link.selectOne", no);
	}

	@Override
	public int delete(Integer no) {
		return template.delete("Link.delete", no);
	}

	@Override
	public int insert(Link item) {
		return template.insert("Link.insert", item);
	}
	
	@Override
	public int update(Link item) {
		return template.update("Link.update", item);
	}

	@Override
	public int countUp(Integer no) {
		return template.update("Link.countUp", no);
	}

	@Override
	public List<String> selectDistinctCatecoryList() {
		return template.selectList("Link.selectDistinctCatecoryList");
	}
	
}
